#!/bin/sh
#-----------------------------------------------------------------------
# @configure_input@
# $Id$
#
# Copyright (c) 2011-2015  Remko Scharroo
# See LICENSE.TXT file for copying and redistribution conditions.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#-----------------------------------------------------------------------
#
# This forms the basis for the rads-config utility, which informs
# users of the configuration of the RADS installation.

configure="@CONFIGURE_OPTIONS@"
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datadir="@datadir@"
datarootdir="@datarootdir@"
bindir="@bindir@"
docdir="@docdir@"
includedir="@includedir@"
libdir="@libdir@"

fc="@FC@"
fflags="@FCFLAGS@ -I${includedir}"
libs="-L${libdir} -lrads @NETCDF_LIB@"
version="@PACKAGE_NAME@ @PACKAGE_VERSION@"
vernum="@PACKAGE_VERSION@"

usage()
{
    cat <<EOF
Usage: $0 [OPTION]

Available values for OPTION include:

  --help        display this help message and exit
  --all         display all options
  --fc          Fortran compiler
  --fflags      flags needed to compile a Fortran program
  --libs        libraries needed to link program
  --configure   configure flags used when building library
  --prefix      install prefix
  --includedir  include directory
  --libdir      library directory
  --bindir      directory for executables
  --datadir     RADS data directory
  --version     RADS library name and version
  --vernum      RADS library version number
EOF

    exit $1
}

all()
{
	echo
	echo "This $version has been built with the following features: "
	echo
	echo "  --fc        -> $fc"
	echo "  --fflags    -> $fflags"
    echo "  --libs      -> $libs"
	echo
	echo "  --configure -> $configure"
	echo "  --prefix    -> $prefix"
	echo "  --includedir-> $includedir"
	echo "  --libdir    -> $libdir"
	echo "  --bindir    -> $bindir"
	echo "  --datadir   -> $datadir"
	echo "  --version   -> $version"
	echo "  --vernum    -> $vernum"
	echo
}

if test $# -eq 0; then
    usage 1
fi

while test $# -gt 0; do
	case "$1" in

	--help)		usage 0 ;;
	--all)		all ;;
	--configure) echo $configure ;;
	--fc)		echo $fc ;;
	--fflags)	echo $fflags ;;
	--libs)		echo $libs ;;
	--prefix)	echo "$prefix" ;;
	--includedir) echo "$includedir" ;;
	--libdir)	echo "$libdir" ;;
	--bindir)	echo "$bindir" ;;
	--datadir)	echo "$datadir" ;;
	--version)	echo $version ;;
	--vernum)	echo $vernum ;;
	*)			echo "$0: unknown option: $1"; usage 1 ;;
	esac
	shift
done

exit 0
